package com.interest.controller;

import com.interest.controller.builder.DefaultModelAndViewBuilder;
import com.interest.controller.builder.ListModelAndViewBuilder;
import com.interest.modules.movie.entity.Movie;
import com.interest.modules.movie.service.MovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * Created by yangfeng on 16-12-5.
 */
@Controller
@RequestMapping("/movie")
public class MovieController {
    @Autowired
    private MovieService movieService;

    @RequestMapping("list")
    public ModelAndView getList() {
        List<Movie> movies = movieService.getMovie();
        return new ListModelAndViewBuilder("movie/list", movies).build();
    }

    @RequestMapping("random")
    public ModelAndView random() {
        return new DefaultModelAndViewBuilder<Movie>("movie/random", movieService.getRandom()).build();
    }
}
